<template>
  <div class="container enroll">
    <auth
      v-if="member"
      :formData="member"
    ></auth>
    <formauth
      v-else
      @submit="onSubmit"
    ></formauth>
  </div>
</template>

<script>
import Formauth from '@/components/formauth/formauth'
import Auth from '@/components/formauth/auth'

import { postMemberApi, getMemberApi } from '@/api'
export default {
  components: {
    Formauth,
    Auth
  },

  data () {
    return {
      member: null
    }
  },
  onShow () {
    this.onLoadData()
  },
  methods: {
    onLoadData () {
      getMemberApi().then(res => {
        this.member = res
        console.log(this.member)
      })
    },
    onSubmit (e) {
      console.log(e)
      postMemberApi(e).then(res => {
        wx.showToast({
          title: '认证信息提交成功'
        })
      })
    }
  }
}
</script>

<style lang="less">
.container {
  background: #f7f7fa;
  padding: 10px;
}
</style>
